package com.coolw.spring.statemachine.enums;

import com.coolw.spring.statemachine.support.BaseState;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.dromara.hutool.core.text.StrUtil;

import java.util.Arrays;

/**
 * 订单状态
 *
 * @author coolw
 * @date 2024/4/8 16:20
 */
@Getter
@AllArgsConstructor
public enum OrderStatusEnum implements BaseState {

    WAIT_PAYMENT("10", "待支付"),
    WAIT_DELIVER("20", "待发货"),
    WAIT_RECEIVE("30", "待收货"),
    FINISH("40", "已完成");

    private final String code;
    private final String desc;

    public static OrderStatusEnum getEnum(String code) {
        return Arrays.stream(values())
                .filter(r -> StrUtil.equals(r.getCode(), code))
                .findFirst()
                .orElse(null);
    }
}
